﻿<%@ Page Title="" Language="C#" MasterPageFile="~/GUI/Admin/QuanLy.master" AutoEventWireup="true" CodeBehind="QL-Album.aspx.cs" Inherits="ProjectWebNhac.GUI.Admin.QL_Album" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script src="js/jquery.min.js" type="text/javascript"></script>


<script type="text/javascript">
    $(document).ready(function () {
        var MaAlbum = $(".hidden-album").val();
        $(".btn-inverse").on("click", function () {

            AddtoAlbum($(this).attr('id'));
        });
        function AddtoAlbum(maBaiHat) {
            var data = "{ 'MaAlbum': '" + MaAlbum + "','MaBaiHat':'" +
                 maBaiHat + "'}";
            $.ajax({
                type: "POST",
                url: "QL-Album.aspx/AddAlbum",
                data: data,
                contentType: "application/json",
                dataType: "json",
                success: function (msg) {
                    if (msg.d) {
                        $('#' + maBaiHat).hide();
                        $('#success' + maBaiHat).show();
                    } else {
                        alert("Bài hát này đã tồn tại");
                    }


                    // Replace the div's content with the page method's return.

                }
            });
        }
    });
    </script>

<div class="page-header">
            <div class="pull-left">
              <h2>Quản Lý Album</h2>
            </div>
            <div class="pull-right">
              <ul class="stats">
                <li class="color-second">
                  <span class="fs1" aria-hidden="true" data-icon=""></span>
                  <div class="details" id="date-time"><span class="big">June 20th 2013</span><span>Thu 09:11:00 am</span></div>
                </li>
              </ul>
            </div>
            <div class="clearfix"></div>
          </div>

          

            <div class="row-fluid">

                <div class="span6">
              <div class="widget no-margin">
                <div class="widget-header">
                  <div class="title">
                    <span class="fs1" aria-hidden="true" data-icon=""></span> Thông Tin Album
                  </div>
                </div>
                <div class="widget-body">
                  <div class="row-fluid">
                    <div class="span4">
                      <div class="thumbnail">
                          <asp:Image ID="imgHinhAnh" runat="server" Width="180"
                              ImageUrl="images/male-avatar-icon-614x460.png" />
                      </div>
                    </div>
 
                    <div class="span6">
                      <form class="form-horizontal no-margin">
                         <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                            Tên 
                             Album</label><div class="span8">
                          <asp:TextBox ID="txtTenAlbum" Enabled="false" runat="server"></asp:TextBox>
                          </div>
                        </div>

                         <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                             Ca Sĩ
                          </label>
                          <div class="span8">
                           <asp:TextBox ID="txtTenCaSi"  Enabled="false" runat="server"></asp:TextBox>
                          </div>
                        </div>

                         <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                             Ngày Phát Hành
                          </label>
                          <div class="span8">
                          <asp:TextBox ID="txtNgayPhatHanh" Enabled="false" runat="server"></asp:TextBox>
                          </div>
                        </div>

                        <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                            Lượt Nghe
                          </label>
                          <div class="span8">
                              <%--<asp:TextBox ID="txtQuocGia" runat="server"></asp:TextBox>--%>
                          <asp:TextBox ID="txtLuotNghe" Enabled="false" runat="server"></asp:TextBox>
                          </div>
                        </div>

                        <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                            Thể Loại Nhạc
                          </label>
                          <div class="span8">
                          <asp:TextBox ID="txtTheLoaiNhac" Enabled="false" runat="server"></asp:TextBox>
                          </div>
                        </div>

                        <div>
                      <asp:FileUpload ID="flhinhanh" runat="server" Enabled="False" />
                    </div>

                      <div class="form-actions " style="float: left; margin-left: -178px; width: 476px;">
                         <div class="span2">
                         <asp:LinkButton ID="lnkThem" 
                                  CssClass="btn btn-primary input-top-margin" runat="server" 
                                   Text="Thêm" onclick="lnkThem_Click" ></asp:LinkButton>

                         </div>
                       
                         <div id="divEdit" class="span2" runat="Server" visible=false>
                            <a href="#formEdit" id="btnEdit" role="button" class="btn btn-primary input-top-margin" data-toggle="modal" data-original-title="">Sửa</a>
                         </div>
                         <div id="AddSong" class="span3" runat="Server" visible="false">
                            <a href="#divAddSong" id="A1" role="button" class="btn btn-primary input-top-margin" data-toggle="modal" data-original-title="">Thêm bài hát</a>
                         </div>
                         <div class="span2">
                         <asp:LinkButton ID="lnkHuy" Visible=false CssClass="btn btn-danger input-top-margin" 
                                    runat="server" onclick="lnkHuy_Click" >Hủy</asp:LinkButton>
                         </div>
                        <div class="span2">
                         <asp:LinkButton ID="lnkThemBaiHat" Visible=false CssClass="btn btn-danger input-top-margin" 
                                    runat="server" >Thêm Bài Hát</asp:LinkButton>
                         </div>
                        </div>  

                      </form>
                    </div>
                  </div>
                  
<div id="formEdit" class="modal hide fade" tabindex="-4" role="dialog" aria-labelledby="myModalLabel4" aria-hidden="true">
                              <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                  ×
                                </button>
                                <h4 id="myModalLabel4">
                                  Sửa thông tin album
                                </h4>
                              </div>
                              <div class="modal-body">
                                
                  <div class="row-fluid">
                    <div class="span4">
                      <div class="thumbnail">
                          <asp:Image ID="imgHinhAnhEdit" runat="server" Width="180"
                              ImageUrl="images/male-avatar-icon-614x460.png" />
                      </div>
                    </div>
 
                    <div class="span6">
                      
                         <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                            Tên Album
                          </label>
                          <div class="span8">
                          <asp:TextBox ID="txtTenAlbumEdit" runat="server" ></asp:TextBox>
                          </div>
                        </div>

                         <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                            Ngày phát hành
                          </label>
                          <div class="span8">
                           <asp:TextBox ID="txtNgayPHEdit"   runat="server"></asp:TextBox>
                          </div>
                        </div>

                         <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                           Thể loại nhạc
                          </label>
                          <div class="span8">
                          <asp:TextBox ID="txtTheLoaiEdit"  runat="Server" ></asp:TextBox>
                          </div>
                        </div>
                        <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                           Tên Ca Sĩ
                          </label>
                          <div class="span8">
                          <asp:TextBox ID="txtTenCSEdit"  runat="Server" ></asp:TextBox>
                          </div>
                        </div>
                        <div style="width: 348px;" class="row-fluid">
                          <label class="span4">
                          Hình Ảnh
                          </label>
                          <div class="span8">
                              <asp:FileUpload ID="flHinhAnhEdit" runat="server" />
                          </div>
                        </div>
                        <div>
                    
                    </div>
                     
                    </div>
                  </div>
                 </div>
                 <div class="modal-footer">


                                <button class="btn" data-dismiss="modal" aria-hidden="true">
                                  Close
                                </button>
                               
                     <asp:Button ID="btnUpdate" CssClass="btn btn-primary" runat="server" Text="Lưu" 
                                    onclick="btnUpdate_Click" Visible="False" 
                                    />
                              </div>
                </div>

                <div id="divAddSong" class="modal hide fade" tabindex="-4" role="dialog" aria-labelledby="myModalLabel4" aria-hidden="true">
                              <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                  ×
                                </button>
                                <h4 id="H1">
                                  Thêm bài hát vào album
                                </h4>
                              </div>
                              <div class="modal-body">
                                
                  <div class="row-fluid">
                    
                    </div>
 
                    <div class="span12">
                         <div class="widget-body">
                  <div id="Div3" class="example_alt_pagination">

                    <div id="Div4" class="dataTables_wrapper" role="grid">
                    
                        <asp:GridView ID="gvSong" runat="server" 
                            CssClass="table table-condensed table-striped table-hover table-bordered pull-left dataTable" 
                            AutoGenerateColumns="False">
                            <Columns>
                                 <asp:BoundField DataField="TenBaiHat" HeaderText="Tên Bài Hát">
                                <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:BoundField DataField="TenCaSi" HeaderText="Tên Ca Sĩ">
                                <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                                </asp:BoundField>
                                  <asp:TemplateField HeaderText="Xử Lý">
                                <ItemTemplate>
                                <input type="button" id="<%#Eval("MaBaiHat") %>" class="btn btn-inverse" value="Thêm" />
                                <input type="button" id="success<%#Eval("MaBaiHat") %>" style="display:none" class="btn btn-success" value="Đã thêm" />
                                </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        </div>
                    <div class="clearfix"></div>
                  </div>
                </div>
                        <div>
                    
                    </div>
                     
                    </div>
                 
                 </div>
                    <asp:TextBox ID="txtMaAlbum" style="display:none" class="hidden-album"  runat="server"></asp:TextBox>
                 <div class="modal-footer">


                                <button class="btn" data-dismiss="modal" aria-hidden="true">
                                  Close
                                </button>
                               
                     <asp:Button ID="Button1" CssClass="btn btn-primary" runat="server" Text="Lưu" 
                                    onclick="btnUpdate_Click" Visible="False" 
                                    />
                              </div>
                </div>
                </div>
              </div>
            </div>
            <div class="span6">
              <div class="widget no-margin">
                <div class="widget-header">
                  <div class="title">
                    <span class="fs1" aria-hidden="true" data-icon=""></span> Danh Sách Bài Hát
                  </div>
                </div>
                <div class="widget-body">
                  <div id="Div1" class="example_alt_pagination">

                    <div id="Div2" class="dataTables_wrapper" role="grid">
                    
                        <asp:GridView ID="gvDSBaiHatAlbum" runat="server" 
                            CssClass="table table-condensed table-striped table-hover table-bordered pull-left dataTable" 
                            AutoGenerateColumns="False" onrowcommand="gvDSBaiHatAlbum_RowCommand" 
                            onrowdatabound="gvDSBaiHatAlbum_RowDataBound1">
                            <Columns>
                              
                                <asp:BoundField DataField="TenBaiHat" HeaderText="Tên Bài Hát" />
                                
                                <asp:BoundField DataField="LuotNghe" HeaderText="Lượt Nghe">
                                <ItemStyle Width="0px" />
                                </asp:BoundField>
                                
                                <asp:TemplateField HeaderText="Trạng Thái">
                                    <ItemTemplate>
                                        <asp:Label ID="lbBhTrangThai" runat="server" Text='<%# Bind("TrangThai") %>'></asp:Label>
                                    </ItemTemplate>
                                   
                                    <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Xử Lý">
                                <ItemTemplate>
                                <asp:LinkButton ID="lnkXoa" CommandArgument='<%#Eval("MaAlbum")%>' CommandName="Xoa"  OnClientClick="javascript:return confirm('Bạn có chắc xóa bài hát này?');"  CssClass="btn btn-inverse" runat="server" Text="Xóa"></asp:LinkButton>
                                </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        </div>
                    <div class="clearfix"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>

       
       
       
          

            <div class="row-fluid">
            <div class="span12">
              <div class="widget no-margin">
                <div class="widget-header">
                  <div class="title">
                    <span class="fs1" aria-hidden="true" data-icon=""></span> Danh Sách AlBum
                  </div>
                </div>
                <div class="widget-body">
                  <div id="dt_example" class="example_alt_pagination">

                    <div id="data-table_wrapper" class="dataTables_wrapper" role="grid">
                    
                        <asp:GridView ID="gvDSAlbum" runat="server" 
                            CssClass="table table-condensed table-striped table-hover table-bordered pull-left dataTable" 
                            AutoGenerateColumns="False" onrowcommand="gvDSAlbum_RowCommand" 
                            onrowdatabound="gvDSAlbum_RowDataBound1">
                            <Columns>
                              
                                <asp:TemplateField HeaderText="Mã Album">
                                <ItemTemplate>
                                    <%--<asp:LinkButton ID="lnkMaAlbum" CommandArgument="<%#Eval("MaAlbum")%>" CommandName="ChiTiet" runat="server"><%#Eval("MaAlbum")%></asp:LinkButton>--%>
                                </ItemTemplate>
                                    <HeaderStyle CssClass="hide" />
                                    <ItemStyle CssClass="hide" />
                                </asp:TemplateField>
                              
                                <asp:TemplateField HeaderText="Hình Ảnh">
                                <ItemTemplate>
                                 <img style="max-height:85px;max-width:85px" src="../../HinhAnh/Album/<%#Eval("HinhAnh")%>">
                                </ItemTemplate>
                                    <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                    <ItemStyle Width="10%" HorizontalAlign="Center" />
                                </asp:TemplateField>
                                
                                <asp:TemplateField HeaderText="Tên Album">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbDetail" CommandArgument='<%#Eval("MaAlbum")%>' CommandName="ChiTiet" runat="server"> <%#Eval("TenAlbum") %></asp:LinkButton>
                               
                                </ItemTemplate>
                                    <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                    <ItemStyle CssClass="gradeX" HorizontalAlign="Center" />
                                </asp:TemplateField>
                                
                                <asp:BoundField DataField="TenCaSi" HeaderText="Ca Sĩ" />
                                
                                <asp:BoundField DataField="TenTheLoai" HeaderText="Thể Loại" >
                                
                                </asp:BoundField>
                                
                                <asp:BoundField DataField="NgayPhatHanh" HeaderText="Ngày Phát Hành">
                                <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                                </asp:BoundField>
                                                               
                                <asp:TemplateField HeaderText="Trạng Thái">
                                    <ItemTemplate>
                                        <asp:Label ID="lblTrangThai" runat="server" Text='<%# Bind("TrangThai") %>'></asp:Label>
                                    </ItemTemplate>
                                    
                                    <HeaderStyle CssClass="hidden-phone" HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Xử Lý">
                                <ItemTemplate>
                                    
                                    <asp:LinkButton ID="lnkKichHoat" Visible="false" CommandArgument='<%#Eval("MaAlbum")%>' CommandName="KichHoat" CssClass="btn btn-success btn-small hidden-phone" runat="server">Kích hoạt</asp:LinkButton>
                                <asp:LinkButton ID="lnkXoa"  Visible="false" CommandArgument='<%#Eval("MaAlbum")%>' OnClientClick="javascript:return confirm('Bạn có chắc xóa album này?');" CommandName="Xoa" CssClass="btn btn-inverse" runat="server" Text="Xóa"></asp:LinkButton>
                                </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        </div>
                    <div class="clearfix"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          



          <script type="text/javascript" charset="utf-8">
              $(document).ready(function () {

                  $("table").dataTable(
        { "sPaginationType": "full_numbers",
            "bPaginate": true,
            "bSort": false,
            "bFilter": true,
            "bInfo": false,
            "bLengthChange": false,
            "iDisplayLength": 5,
            "bJQueryUI": false
            });

                  var txtTenAlbum = $('#<%=txtTenAlbum.ClientID %>');
                  var txtTenAlbumEdit = $('#<%=txtTenAlbumEdit.ClientID %>');
                  var txtTenCaSi = $('#<%=txtTenCaSi.ClientID %>');
                  var txtTenCSEdit = $('#<%=txtTenCSEdit.ClientID  %>');
                  var txtNgayPhatHanh = $('#<%=txtNgayPhatHanh.ClientID %>');
                  var txtNgayPHEdit = $('#<%=txtNgayPHEdit.ClientID %>');
                  var txtTheLoaiNhac = $('#<%=txtTheLoaiNhac.ClientID %>');
                  var txtTheLoaiEdit = $('#<%=txtTheLoaiEdit.ClientID %>');
                  var src = $('#<%=imgHinhAnh.ClientID %>').attr('src');
                  var imgHinhAnhEdit = $('#<%=imgHinhAnhEdit.ClientID %>');
                  $('#btnEdit').click(function () {
                      txtTenAlbumEdit.val(txtTenAlbum.val());
                      txtTenCSEdit.val(txtTenCaSi.val());
                      txtNgayPHEdit.val(txtNgayPhatHanh.val());
                      txtTheLoaiEdit.val(txtTheLoaiNhac.val());
                     
                      imgHinhAnhEdit.attr('src', src);
                  });
              }); 
          </script>
</asp:Content>
